home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_11 / 9n11072a < prev    next >
Text File  |  1991-08-27  |  808b  |  23 lines

  1. Listing 4:
  2.  
  3.  
  4. #       compiled using cc -O -S fib.c
  5. _fib:
  6.         save            %sp,-96,%sp         # make space for new frame
  7.         cmp             %i0,2               # determine if n<2
  8.  
  9.         ble,a           L77007
  10.         mov             1,%i0               # annuled if branch not taken
  11.         call            _fib,1
  12.         sub             %i0,2,%o0           # determine n-2
  13.         mov             %o0,%i5             # copy fib(n-2) result
  14.         call            _fib,1
  15.         sub             %i0,1,%o0           # determine n-1
  16.         add             %o0,%i5,%o0         # add fib(n-2) and fib(n-1)
  17.         mov             %o0,%i0             # result in %i0 (%o0 of caller)
  18. L77007:
  19.         ret
  20.         restore                     # return frame registers to stack
  21.  
  22.  
  23.